home *** CD-ROM | disk | FTP | other *** search
/ HTBasic 9.3 / HTBasic 9.3.iso / 93win / data1.cab / DLL_Toolkit / Source / HTBImage / HTBImage.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2005-03-02  |  3.7 KB  |  190 lines

  1. // HTBImage.cpp : Defines the initialization routines for the DLL.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "HTBImage.h"
  6. #include "image.h"
  7. #include "export.h"
  8.  
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14.  
  15. //
  16. //    Note!
  17. //
  18. //        If this DLL is dynamically linked against the MFC
  19. //        DLLs, any functions exported from this DLL which
  20. //        call into MFC must have the AFX_MANAGE_STATE macro
  21. //        added at the very beginning of the function.
  22. //
  23. //        For example:
  24. //
  25. //        extern "C" BOOL PASCAL EXPORT ExportedFunction()
  26. //        {
  27. //            AFX_MANAGE_STATE(AfxGetStaticModuleState());
  28. //            // normal function body here
  29. //        }
  30. //
  31. //        It is very important that this macro appear in each
  32. //        function, prior to any calls into MFC.  This means that
  33. //        it must appear as the first statement within the 
  34. //        function, even before any object variable declarations
  35. //        as their constructors may generate calls into the MFC
  36. //        DLL.
  37. //
  38. //        Please see MFC Technical Notes 33 and 58 for additional
  39. //        details.
  40. //
  41.  
  42. /////////////////////////////////////////////////////////////////////////////
  43. // CHTBImageApp
  44.  
  45. BEGIN_MESSAGE_MAP(CHTBImageApp, CWinApp)
  46.     //{{AFX_MSG_MAP(CHTBImageApp)
  47.         // NOTE - the ClassWizard will add and remove mapping macros here.
  48.         //    DO NOT EDIT what you see in these blocks of generated code!
  49.     //}}AFX_MSG_MAP
  50. END_MESSAGE_MAP()
  51.  
  52. /////////////////////////////////////////////////////////////////////////////
  53. // CHTBImageApp construction
  54.  
  55. CHTBImageApp::CHTBImageApp()
  56. {
  57.     // TODO: add construction code here,
  58.     // Place all significant initialization in InitInstance
  59. }
  60.  
  61. /////////////////////////////////////////////////////////////////////////////
  62. // The one and only CHTBImageApp object
  63.  
  64. CHTBImageApp theApp;
  65. Image * g_pImageList = NULL;
  66.  
  67. extern "C"
  68. {
  69.  
  70. short Loadimage(char * ImageFilename)
  71. {
  72.     Image * pNewImage = NULL;
  73.     
  74.     if (g_pImageList != NULL)
  75.     {
  76.         pNewImage = g_pImageList->AddImage();
  77.     }
  78.     else
  79.     {
  80.         g_pImageList = new Image();
  81.         pNewImage = g_pImageList;
  82.     }
  83.  
  84.     pNewImage->LoadImage(ImageFilename);
  85.  
  86.     return(pNewImage->GetID());
  87. }
  88.  
  89. void Show(short ID,short Xpos,short Ypos,DWORD RasterOp)
  90. {
  91.     if (g_pImageList)
  92.     {
  93.         g_pImageList->Show(ID,Xpos,Ypos,RasterOp);
  94.         RefreshScreen();
  95.     }
  96. }
  97.  
  98. void Noshow(short ID)
  99. {
  100.     if (g_pImageList)
  101.     {
  102.         g_pImageList->NoShow(ID);
  103.         RefreshScreen();
  104.     }
  105.  
  106. }
  107.  
  108. void On_LeftMouseDown(CPoint * point)
  109. {
  110.     if (g_pImageList)
  111.     {
  112.         g_pImageList->EvalRegion(*point);
  113.     }
  114. }
  115.  
  116. void On_RightMouseDown(CPoint * point)
  117. {
  118.     if (g_pImageList)
  119.     {
  120.         g_pImageList->EvalRegionForDrag(*point,TRUE);
  121.     }
  122. }
  123.  
  124. void On_RightMouseUp(CPoint * point)
  125. {
  126.     if (g_pImageList)
  127.     {
  128.         g_pImageList->EvalRegionForDrag(*point,FALSE);
  129.     }
  130. }
  131.  
  132. void On_MouseMove(CPoint * point)
  133. {
  134.     if (g_pImageList)
  135.     {
  136.         g_pImageList->SetDraggingToMouse(*point);
  137.     }
  138. }
  139.  
  140. void Createregion(short ID,short signal,short AllowDrag)
  141. {
  142.     if (g_pImageList)
  143.     {
  144.         g_pImageList->CreateRegion(ID,signal,AllowDrag);
  145.     }
  146.  
  147.     SetExportFunction(L_BTN_DOWN,(void *)On_LeftMouseDown);
  148.     
  149.     if (AllowDrag)
  150.     {
  151.         SetExportFunction(R_BTN_DOWN,(void *)On_RightMouseDown);
  152.         SetExportFunction(R_BTN_UP,(void *)On_RightMouseUp);
  153.         SetExportFunction(MOUSE_MOVE,(void *)On_MouseMove);
  154.     }
  155. }
  156.  
  157. void On_Draw(HDC hDC)
  158. {
  159.     if (g_pImageList)
  160.     {
  161.         g_pImageList->Draw(hDC);
  162.     }
  163. }
  164.  
  165. void Shutdown()
  166. {
  167.     SetExportFunction(ON_DRAW,NULL);
  168.     SetExportFunction(L_BTN_DOWN,NULL);
  169.     SetExportFunction(R_BTN_DOWN,NULL);
  170.     SetExportFunction(R_BTN_UP,NULL);
  171.     SetExportFunction(MOUSE_MOVE,NULL);
  172.  
  173.     if (g_pImageList)
  174.     {
  175.         delete g_pImageList;
  176.         g_pImageList = NULL;
  177.     }
  178.  
  179. }
  180.  
  181. } // end extern "C"
  182.  
  183. BOOL CHTBImageApp::InitInstance() 
  184. {
  185.     SetExportFunction(ON_DRAW,(void *)On_Draw);
  186.  
  187.     return CWinApp::InitInstance();
  188. }
  189.  
  190.